package com.xxmassdeveloper.mpchartexample.util;

import android.content.Context;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created by Fcy on 2015/12/13.<br/>
 */
public class RawUtils {
    public static String getJsonString(Context context, int rawId) {
        InputStream inputStream = context.getResources().openRawResource(rawId);
        return readStream(inputStream);
    }

    private static String readStream(InputStream is) {
        try {
            ByteArrayOutputStream bo = new ByteArrayOutputStream();
            int i = is.read();
            while (i != -1) {
                bo.write(i);
                i = is.read();
            }

            return bo.toString();
        } catch (IOException e) {
            return "";
        }
    }
}
